<?xml version="1.0" encoding="utf-8" ?> 
<sqlMap namespace="QqOnline"
	xmlns="http://ibatis.apache.org/mapping" 
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
	<alias>
		<typeAlias alias="QqOnline" type="Domain.QqOnline" />
	</alias>

	<resultMaps>
		<resultMap id="FullResultMap" class="QqOnline">
			<result property="id" column="id" dbType="Int"/>
			<result property="name" column="name" dbType="NVarChar"/>
			<result property="qqNumber" column="qqNumber" dbType="NVarChar"/>
			<result property="qqOrder" column="qqOrder" dbType="Int"/>
		</resultMap>
	</resultMaps>
	
	<statements>

		<select id="GetCount" resultClass="System.Int32">
			SELECT count(*) FROM [dbo].[qqOnline]
		</select>
		
		<select id="GetCountByCondition" parameterClass="Hashtable" resultClass="System.Int32" extends="GetCount">
			WHERE $condition$
		</select>
		
		<select id="FindAll" resultClass="QqOnline">
			SELECT * 
			FROM [dbo].[qqOnline]
		</select>
		
		<select id="GetModel" parameterClass="QqOnline" resultClass="QqOnline" extends="FindAll">
			WHERE
				([qqOnline].[id] = #id,dbType=Int#)
		</select>

		<insert id="Insert" parameterClass="QqOnline">
			INSERT INTO [dbo].[qqOnline] (
				
				[name] , 
				[qqNumber] , 
				[qqOrder]
			) VALUES (
				
				 #name,dbType=NVarChar# , 
				 #qqNumber,dbType=NVarChar# , 
				 #qqOrder,dbType=Int#
			)
		</insert>

		<update id="Update" parameterClass="QqOnline">
			UPDATE [dbo].[qqOnline] SET
				 [name] = #name,dbType=NVarChar#
				, [qqNumber] = #qqNumber,dbType=NVarChar#
				, [qqOrder] = #qqOrder,dbType=Int#
			WHERE
				([id] = #id,dbType=Int#)
		</update>

		<delete id="Delete" parameterClass="QqOnline">
			DELETE FROM [dbo].[qqOnline]
			WHERE
				([id] = #id,dbType=Int#)
		</delete>

		<select id="GetModelsByCondition" parameterClass="Hashtable" resultClass="QqOnline">
			SELECT $columnNames$ FROM [dbo].[qqOnline] where $condition$
		</select>
		
		<select id="GetModelsByConditionByPager" parameterClass="Hashtable" resultClass="QqOnline">
      declare @indextable table(rno int identity(1,1),nid int)
      insert into @indextable(nid) select [id] from [dbo].[qqOnline]
      where $condition$ order by $orderBy$

      select $columnNames$ from
      [dbo].[qqOnline] ,@indextable t
      <![CDATA[
			where t.nid= [qqOnline].id and t.rno>#startNo# and t.rno<=#endNo# 
      order by t.rno asc
			]]>
		</select>
		
	</statements>
</sqlMap>
